//
//  RoadLineCell.m
//  TT
//
//  Created by Lenny on 16/5/6.
//  Copyright © 2016年 Lenny. All rights reserved.
//

#import "RoadLineCell.h"

@interface RoadLineCell ()

@property(nonatomic,strong)UIImageView *imgV;
@property(nonatomic,strong)UILabel *numL;
@property(nonatomic,strong)UILabel *timeL;
@property(nonatomic,strong)UILabel *longL;
@property(nonatomic,strong)UILabel *userTimeL;

@end

@implementation RoadLineCell

#pragma mark - life cycle

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self UI];
    }
    return self;
}

#pragma mark - private motheds
- (void)UI {
    
    [self addSubview:self.imgV];
    UIView *downV = [[UIView alloc] init];
    downV.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.7];
    [self addSubview:downV];
    [downV addSubview:self.numL];
    [downV addSubview:self.timeL];
    [downV addSubview:self.longL];
    [downV addSubview:self.userTimeL];
    
    UIImageView *timeIV = [[UIImageView alloc] init];
    timeIV.image = [UIImage imageNamed:@"icon_time"];
    [downV addSubview:timeIV];
    
    UIImageView *longIV = [[UIImageView alloc] init];
    longIV.image = [UIImage imageNamed:@"icon_time"];
    [downV addSubview:longIV];
    
    UILabel *userL = [[UILabel alloc] init];
    userL.text = @"使用时间";
    userL.textColor = WL_Desc_Color;
    userL.font = [UIFont systemFontOfSize:10];
    [downV addSubview:userL];
    
    __weak typeof(self) weakSelf = self;
    [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    [downV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];
    
    [self.numL mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(10);
        make.centerY.equalTo(downV);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    
    [timeIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.numL.mas_right).offset(5);
        make.centerY.equalTo(downV);
    }];
    
    [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(downV);
        make.left.equalTo(timeIV.mas_right);
    }];
    
    [longIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(downV);
        make.left.equalTo(weakSelf.timeL.mas_right).offset(10);
    }];
    
    [self.longL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(downV);
        make.left.equalTo(longIV.mas_right);
    }];
    
    [userL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(downV);
        make.left.equalTo(weakSelf.longL.mas_right).offset(10);
    }];
    
    [self.userTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(downV);
        make.left.equalTo(userL.mas_right).offset(10);
    }];
}

#pragma mark - setters and getters 
- (UIImageView *)imgV {
    
    if (_imgV == nil) {
        _imgV = [[UIImageView alloc] init];
        _imgV.backgroundColor = [UIColor yellowColor];
    }
    return _imgV;
}

- (UILabel *)numL {
    
    if (_numL == nil) {
        _numL = [[UILabel alloc] init];
        _numL.text = @"1";
        _numL.layer.cornerRadius = 10;
        _numL.textColor = [UIColor whiteColor];
        _numL.backgroundColor = [UIColor redColor];
        _numL.clipsToBounds = YES;
        _numL.font = [UIFont systemFontOfSize:20];
        _numL.textAlignment = NSTextAlignmentCenter;
    }
    return _numL;
}

- (UILabel *)timeL {
    
    if (_timeL == nil) {
        
        _timeL = [[UILabel alloc] init];
        _timeL.text = @"2016.03.07 14:20-15:00";
        _timeL.textColor = WL_Desc_Color;
        _timeL.font = [UIFont systemFontOfSize:10];
    }
    return _timeL;
}

- (UILabel *)longL {
    
    if (_longL == nil) {
        
        _longL = [[UILabel alloc] init];
        _longL.text = @"全程36KM";
        _longL.font = [UIFont systemFontOfSize:10];
        _longL.textColor = WL_Desc_Color;
    }
    return _longL;
}

- (UILabel *)userTimeL {
    
    if (_userTimeL == nil) {
        
        _userTimeL = [[UILabel alloc] init];
        _userTimeL.text = @"05时23分";
        _userTimeL.textColor = WL_Desc_Color;
        _userTimeL.font = [UIFont systemFontOfSize:15];
    }
    return _userTimeL;
}

@end
